package org.mat.ipaas.ucenter.service.api.quartz;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.mat.framework.lang.dto.MatApiResponse;
import org.mat.ipaas.ucenter.service.dto.quartz.QuartzJobDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 定时任务在线管理
 * @Date: 2019-01-02
 * @Version:V1.0
 */
@FeignClient(name = "mat-ipaas-ucenter-service", contextId = "quartz-job-rest-api")
@Api(tags = "定时任务接口")
public interface QuartzJobRestAPI {

    /**
     * 分页列表查询
     *
     * @param quartzJobDTO
     * @param pageNo
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/sys/quartzJob/list", method = RequestMethod.GET)
    MatApiResponse<?> queryPageList(@SpringQueryMap QuartzJobDTO quartzJobDTO,
                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize);

    /**
     * 添加定时任务
     *
     * @param quartzJobDTO
     * @return
     */
    //@RequiresRoles("admin")
    //@RequiresPermissions("system:quartzJob:add")
    @RequestMapping(value = "/sys/quartzJob/add", method = RequestMethod.POST)
    MatApiResponse<?> add(@RequestBody QuartzJobDTO quartzJobDTO);

    /**
     * 更新定时任务
     *
     * @param quartzJobDTO
     * @return
     */
    //@RequiresRoles("admin")
    //@RequiresPermissions("system:quartzJob:edit")
    @RequestMapping(value = "/sys/quartzJob/edit", method = {RequestMethod.POST})
    MatApiResponse<?> eidt(@RequestBody QuartzJobDTO quartzJobDTO);

    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    //@RequiresRoles("admin")
    //@RequiresPermissions("system:quartzJob:delete")
    @RequestMapping(value = "/sys/quartzJob/delete", method = RequestMethod.DELETE)
    MatApiResponse<?> delete(@RequestParam(name = "id", required = true) String id);

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    //@RequiresRoles("admin")
    //@RequiresPermissions("system:quartzJob:deleteBatch")
    @RequestMapping(value = "/sys/quartzJob/deleteBatch", method = RequestMethod.DELETE)
    MatApiResponse<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids);

    /**
     * 暂停定时任务
     *
     * @param id
     * @return
     */
    //@RequiresRoles("admin")
    //@RequiresPermissions("system:quartzJob:pause")
    @GetMapping(value = "/sys/quartzJob/pause")
    @ApiOperation(value = "停止定时任务")
    MatApiResponse<Object> pauseJob(@RequestParam(name = "id") String id);

    /**
     * 启动定时任务
     *
     * @param id
     * @return
     */
    //@RequiresRoles("admin")
    //@RequiresPermissions("system:quartzJob:resume")
    @GetMapping(value = "/sys/quartzJob/resume")
    @ApiOperation(value = "启动定时任务")
    MatApiResponse<Object> resumeJob(@RequestParam(name = "id") String id);

    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/sys/quartzJob/queryById", method = RequestMethod.GET)
    MatApiResponse<?> queryById(@RequestParam(name = "id", required = true) String id);

    /**
     * 导出excel
     *
     * 
     * @param quartzJobDTO
     */
    @RequestMapping(value = "/sys/quartzJob/exportXls")
    ModelAndView exportXls( QuartzJobDTO quartzJobDTO);

    /**
     * 通过excel导入数据
     *
     * 
     * 
     * @return
     */
    @RequestMapping(value = "/sys/quartzJob/importExcel", method = RequestMethod.POST)
    MatApiResponse<?> importExcel( ) throws IOException;

    /**
     * 立即执行
     *
     * @param id
     * @return
     */
    //@RequiresRoles("admin")
    //@RequiresPermissions("system:quartzJob:execute")
    @GetMapping("/sys/quartzJob/execute")
    MatApiResponse<?> execute(@RequestParam(name = "id", required = true) String id);

}
